package cn.yr.common.core.domain.dto;


import cn.yr.common.core.domain.entity.SysMenu;
import lombok.Data;

import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Treeselect树结构实体类
 *
 * @author ruoyi
 */
@Data
public class TreeSelectDto implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 * 节点ID
	 */
	private Long id;

	/**
	 * 节点名称
	 */
	private String label;

	/**
	 * 子节点
	 */
	private List<TreeSelectDto> children;

	public TreeSelectDto() {}

	public TreeSelectDto(SysMenu menu) {
		this.id = menu.getMenuId();
		this.label = menu.getMenuName();
		this.children = menu.getChildren().stream().map(TreeSelectDto::new).collect(Collectors.toList());
	}

}
